<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/plugins/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/global.css" media="all">
    <link rel="stylesheet" href="/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/table.css"/>
    <title>编辑概括列表</title>
    <style type="text/css">
        .searcheBottom{margin-bottom: 10px;}
    </style>
</head>
<body>
<div class="admin-main">
    <blockquote class="layui-elem-quote demoTable">
        <div class="layui-inline searcheBottom">
            货币简称：
            <div class="layui-inline">
                <input id="symbol" class="layui-input" name="symbol" autocomplete="off" placeholder="货币简称"/>
            </div>
        </div>
        <div class="layui-inline searcheBottom">
            <a class="layui-btn" data-type="reload" id="search">搜索</a>
            <a class="layui-btn layui-btn-primary" id="reset">重置</a>
        </div>
    </blockquote>
    <span style="font-size: 16px;"><b>交易对列表</b></span>
    <table class="layui-hide" id="tableID" lay-filter="tableFilter"></table>

</div>
<script type="text/javascript" src="/plugins/layui/layui.js"></script>
<script>
    layui.use(['jquery','table','laydate','layer','form','util'],function(){
        var $=layui.jquery,table=layui.table,laydate = layui.laydate,
            layer = layui.layer,form = layui.form,util=layui.util;

        pageInit();
        //表格渲染
        function pageInit(){
            table.render({
                elem:"#tableID",
                url:"/manage/summarize/coinsunList",
                method:"post",
                cols:[[
                    {field:'id', title: 'ID', sort: true,align:'center'},
                    {field:'coinNameEn', title: '货币名称',align:'center'},
                    {field:'symbol', title: '货币简称',align:'center'},
                    {field:'title', title: '标题',align:'center'},
                    {field:'intruduction', title: '项目简介',align:'center'},
                    {field:'releaseTime', title: '发行时间',align:'center',templet: function(d){
                        if(d.releaseTime!=null){
                            return util.toDateString(d.releaseTime, 'yyyy-MM-dd');
                        }else{
                            return '';
                        }
                    }},
                    {field:'releasePrice', title: '发行价格',align:'center'},

                    {field:'releaseTotal', title: '发行总量',align:'center'},

                    {field:'publicOfferTime', title: '公募时间',align:'center',
                        templet: function(d){
                        if(d.publicOfferTime!=null){
                            return util.toDateString(d.publicOfferTime, 'yyyy-MM-dd');
                        }else{
                            return '';
                        }
                    }},
                    {field:'icoCost', title: '公募成本',align:'center'},
                    {field:'raiseFunds', title: '募集资金',align:'center'},
                    {field:'tokenDistribution', title: '代币分配',align:'center'},
                    {field:'websiteLink', title: '官网链接',align:'center'},
                    {field:'whitePaper', title: '白皮书',align:'center'},
                    {field:'supportPurse', title: '支持钱包',align:'center'},
                    {field:'createTime', title: '添加时间',align:'center',sort:true,
                        templet: function(d){
                            if(d.createTime!=null){
                                return util.toDateString(d.createTime, 'yyyy-MM-dd HH:mm:ss');
                            }else{
                                return '';
                            }
                        }
                    },
                    {field:'updateTime', title: '修改时间',align:'center',sort:true,
                        templet: function(d){
                            if(d.updateTime!=null){
                                return util.toDateString(d.updateTime, 'yyyy-MM-dd HH:mm:ss');
                            }else{
                                return '';
                            }

                        }
                    },
                    {field: 'tool', title:"操作",align:'left',width:80,align:'center',
                        templet:function(d){
                            var tool = '';
                            if(d.intruduction==null){
                                tool+='<a href="#" class="layui-btn layui-btn-xs" lay-event="add">新增</a>';
                            }else{
                                tool+='<a href="#" class="layui-btn layui-btn-warm layui-btn-xs" lay-event="edit">编辑</a>';
                            }
                            return tool;
                        }
                    }
                ]],
                limits:[10,15,20,25,30],
                limit:10,
                page:true
            });
        };

        var active = {
            reload: function () {
                var symbol = $('#symbol');
                table.reload('tableID', {
                    where: {
                        symbol: symbol.val()
                    }
                });
            }
        };

        //将搜索框的值随请求传到后台
        $('.demoTable #search').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        $(".layui-input").keydown(function (e) {
            if(e.keyCode == 13){
                $('#search').click();
            }
        });

        //重置
        $("#reset").on("click",function(){
            symbol.value='';
        });

        //表格监听
        table.on('tool(tableFilter)', function(obj){
            var data = obj.data;
            if (obj.event == "add") {
                location.href='/manage/summarize/addSumarPage?id='+data.id;
            }else if(obj.event == "edit"){
                location.href='/manage/summarize/encapsulate?id='+data.id;
            }
        });
    });
</script>
</body>
</html>